package com.itheima.controller;

import com.itheima.domain.User;
import com.itheima.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author Mr.Shen
 * @date 2020-02-13 19:40
 */
@Controller
@RequestMapping("/user")

public class UserController {
    @Autowired
    private IUserService userService;

    @RequestMapping("/findAll")
    public @ResponseBody
    List<User> findAll(){
        System.out.println("test");
        return userService.findAll();
    }
    @RequestMapping("findById")
    public @ResponseBody
    User findById(Integer id){
        return userService.findById(id);
    }
    @RequestMapping("/updateUser")
    public void updateUser(@RequestBody User user){
        System.out.println("user = " + user);
        userService.updateUser(user);
    }
}
